Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve bug that prevented sending StoredVmQuota and DeployedVmQuota when creating/updating Org User #445

Merged
merged 2 commits into from
Mar 22, 2022

Conversation

mikeletux
Copy link
Contributor

@mikeletux mikeletux commented Mar 9, 2022

This PR is related vmware/terraform-provider-vcd#799

Description

This PR aims to solve a bug reported on vmware/terraform-provider-vcd#799. When trying to update a user from whatever quota to 0 (unlimited), it wasn't working. Creating was working.

Detailed description

VCD Terraform provider, when updating an user it was using the method OrgUser.Update(). Turns out that after doing some troubleshooting, I've spotted that on struct types.User the attributes StoredVmQuota and DeployedVmQuota had the omitempty tag, which was preventing to send these fields on the PUT HTTP request when updating if they were set to 0, because Go recognizes this as the empty value and doesn't sent it.

The outcome of this was the API returning a 200 OK but these fields not being set to 0 (unlimited quota) because everything else was being update but those two fields, since they were not included in the request.

When creating a user it was working if set to 0, because if the API receives a POST request without these two fields, it set them to 0 (unlimited) by default.

To solve this, those two fields were removed that xml tag, so this fields is always sent in all PUT requests:

...
StoredVmQuota   int              `xml:"StoredVmQuota"`
DeployedVmQuota int              `xml:"DeployedVmQuota"`
...

Also Test_UserCRUD has been updated to test OrgUser.Update() and check this edge case.

Miguel Sama added 2 commits March 9, 2022 12:46
…dVmQuota to 0

Signed-off-by: Miguel Sama <msama@vmware.com>
…t to 0

Signed-off-by: Miguel Sama <msama@vmware.com>
Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Before merging, please converge on this discussion #445 (comment) with @vbauzysvmware though.

@mikeletux mikeletux merged commit 5ad8d90 into vmware:main Mar 22, 2022
@mikeletux mikeletux deleted the 799-bug-vcd-org-user-quota-0 branch March 22, 2022 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants